package com.lovvyang.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Enumeration;

/**
 * @author lovvyang
 * @date 2020/6/8-13:04
 */
@WebServlet("/RequestDemo03")
public class RequestDemo03 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       //中文乱码
        request.setCharacterEncoding("utf-8");

        //获取请求参数
       /* String username = request.getParameter("username");
        System.out.println(username);
        System.out.println("-------------");*/

        //请求转发
        //共享数据
        //获取ServletContext
        request.setAttribute("name","yuanyue");
        request.getRequestDispatcher("/RequestDemo04").forward(request,response);
        System.out.println("demo08");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);

    }
}
